package com.itheima.consumer.Consumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class consumer01 {
    @RabbitListener(bindings = @QueueBinding(
            value =@Queue(name = "queue02"),
            exchange = @Exchange(name = "exchange02",type = ExchangeTypes.DIRECT),
            key = {"zky"}
    ))
    void testConsumer(String msg) throws InterruptedException {
        //如果抛出异常后会将消息路由到指定队列
        log.info("消费者收到消息:{}",msg);
    }
}
